package com.atguigu.gulimail.search.controller;

import com.atguigu.gulimail.search.service.MailSearchService;
import com.atguigu.gulimail.search.vo.SearchParam;
import com.atguigu.gulimail.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class SearchController {

    @Autowired
    MailSearchService mailSearchService;


    /**
     * 根据穿过来的条件 ， 封装对象
     *
     * @return
     */

    @GetMapping("/list.html")
    public String list(SearchParam param, Model model) {

        SearchResult result = mailSearchService.search(param);

        model.addAttribute("result", result);

        return "list";
    }
}
